﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using University.Workshop.DataAccess;
using University.Workshop.Model;

namespace University.Workshop.Business
{
    public static class SendMailManager
    {
        public static void ValidateToSend(string user,string password,string subject,string email,string message,string file) 
        {
            if (string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(email) ||string.IsNullOrEmpty(message))
                throw new ArgumentException("All inputs are required.");
            
            if (!Regex.IsMatch(email, @"^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})| ([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$"))
                throw new ArgumentException("the format the email is incorrect");
            SendMail send = new SendMail();
            send.Dispose();
            send.SendMessage(new MyEmail { To = user, From = email, Subject = subject, Message = message, Password = password, File = file });

        }
     }
}
